home *** CD-ROM | disk | FTP | other *** search
/ Monster Media 1994 #2 / Monster Media No. 2 (Monster Media)(1994).ISO / prog_gen / ada_tutr.zip / CHANGESN.ADA < prev    next >
Text File  |  1994-08-22  |  2KB  |  52 lines

  1. -- CHANGESN.ADA   Ver. 3.00   22-AUG-1994   Copyright 1988-1994 John J. Herro
  2. -- Software Innovations Technology
  3. -- 1083 Mandarin Drive NE, Palm Bay, FL  32905-4706   (407)951-0233
  4. --
  5. -- Used to change the serial number in ADA_TUTR.DAT after registering.
  6. --
  7. with Text_IO, Direct_IO; use Text_IO;
  8. procedure ChangeSN is
  9.    subtype Block_Subtype is String(1 .. 64);
  10.    package Random_IO is new Direct_IO(Block_Subtype); use Random_IO;
  11.    Data_File_Name : constant String := "ADA_TUTR.DAT";
  12.    Data_File      : Random_IO.File_Type;
  13.    Block          : Block_Subtype;            -- Block read from the data file.
  14.    Block_Num      : Random_IO.Count := 40;      -- Number of the current block.
  15.    Place          : Integer;                 -- Index to search for "Serial #".
  16.    Found          : Boolean := False;         -- True when "Serial #" is found.
  17.    Serial_Num     : String(1 .. 5);             -- The serial number, in ASCII.
  18.    Input          : String(1 .. 6);                     -- Input that you type.
  19.    Len            : Integer;                          -- Length of typed input.
  20.    Legal_Note     : constant String := " Copyright 1988-94 John J. Herro ";
  21.                        -- Legal_Note isn't used by the program, but it causes
  22.                        -- most compilers to place this string in the .EXE file.
  23. begin
  24.    Random_IO.Open(Data_File, Mode => Inout_File, Name => Data_File_Name);
  25.    while not Found loop
  26.       Block_Num := Block_Num + 1;
  27.       Read(File => Data_File, Item => Block, From => Block_Num);
  28.       Place := 0;
  29.       while not Found and Place <= 50 loop
  30.          Place := Place + 1;
  31.          Found := Block(Place .. Place + 7) = "Serial #";
  32.       end loop;
  33.    end loop;
  34.    Serial_Num := Block(Place + 10 .. Place + 14);
  35.    Put_Line("Old serial number is " & Serial_Num & ".");
  36.    Put("New serial number:   ");
  37.    Input := Serial_Num & " ";
  38.    Get_Line(Input, Len);
  39.    New_Line;
  40.    Block(Place + 10 .. Place + 14) := Input(1 .. 5);
  41.    Write(File => Data_File, Item => Block, To => Block_Num);
  42.    Close(Data_File);
  43.    Put_Line("Serial number changed to " & Input(1 .. 5) & ".");
  44. exception
  45.    when Random_IO.Name_Error =>
  46.       Put("I'm sorry.  The file " & Data_File_Name);
  47.       Put_Line(" seems to be missing.");
  48.    when Random_IO.End_Error =>
  49.       Put("I'm sorry.  I couldn't find a serial number in ");
  50.       Put_Line(Data_File_Name & ".");
  51. end ChangeSN;
  52.